import { extend } from '@/services/request';
import { RUC_SERVICE, ACE_BPM, TS_STOCK } from './constant';
// import { Request } from './axios-config';
// import { Request } from '@/services/index';
// import { GLOBAL_API } from '@/services/constants';

const request = extend({
  prefix: ACE_BPM
});

const requestBPM = extend({
  prefix: ACE_BPM
});

const requestTS = extend({
  prefix: TS_STOCK
});

// 保存表单数据
export interface IReqFormSave {
  formId: string;
  formJson: string;
}
// export async function saveFormData(params: IReqFormSave) {
//   return request('/flowableForm/save', {
//     method: 'POST',
//     contentType: 'application/json',
//     data: { ...params },
//   });
// }

// 添加申报发放明细
export interface GrandDetailItem {
  innerProcDefId: string;
  price: string;
  quantity: string;
  remark: string;
  standardId: string;
  standardName: string;
  unit: string;
  studentName: string;
  studentCode: string;
}

export interface CostTypeInterface {
  applyType?: string;
  projectHeadNumber?: string;
  projectTailNumber?: string;
  uerType?: string;
}

export interface IUrgingProcessReq {
  procNo: string;
  procName: string;
  innerProcDefId: string;
  procInstId: string;
  taskDefKey: string;
}

// 添加劳务申报 发放明细表详情
export async function addGrandDeatilItem(params: GrandDetailItem) {
  return request('/provideItem/v1/provideItem/add', {
    method: 'POST',
    contentType: 'application/json',
    data: { ...params }
  });
}

// 获取劳务申报 发放明细表详情
export async function getGrandDeatilItem(id: string) {
  return request(`/provideItem/v1/provideItem/detail/${id}`, {
    method: 'POST'
  });
}

// 删除劳务申报 发放明细表详情
export async function delGrandDeatilItem(id: string) {
  return request(`/provideItem/v1/provideItem/delete/${id}`, {
    method: 'POST'
  });
}

// 编辑劳务申报 发放明细表详情
export async function emitGrandDeatilItem(params: GrandDetailItem) {
  return request('/provideItem/v1/provideItem/edit', {
    method: 'GET',
    data: { ...params }
  });
}

// 学生劳务申报列表
export const getStudyServiceApply = async (params = {}) => {
  return request('/taskRecord/my/apply/list', {
    method: 'POST',
    data: { ...params }
  });
};

// 获取申报发放明细表列表-不分页
export const GetProvideItem = async (params = {}) => {
  return request('/api/provideItem/v1/provideItem/list', {
    method: 'POST',
    data: { ...params }
  });
};

// 获取申报发放明细表列表-分页
export const GetProvideList = async (params = {}) => {
  return request('/api/provideItem/v1/provideItem/table/list', {
    method: 'POST',
    data: { ...params }
  });
};

// 删除草稿
export const DelRucDraft = async (params = '') => {
  return request('/api/rucDraft/delete/' + params, {
    method: 'POST'
  });
};

// 删除明细附件
export const DelReport = async (params = '') => {
  return request('/attachment/delete?id=' + params, {
    method: 'GET'
  });
};

// 获取业务审批详情
export const GetRucDraftAudit = async (params = {}) => {
  return requestTS('/draft/audit/detail', {
    method: 'POST',
    data: { ...params }
  });
};

// 获取审批详情
export const GetRucApplyDetail = async (params: any) => {
  console.log('params--{}',params);
  return request(`/procRecord/procDetail?procRecordId=${params.procRecordId}`, {
    method: 'GET'
  });
};

// 获取业务草稿详情
export const GetRucDraftDetail = async (params = '') => {
  return requestTS(`/draft/detail/${params}`, {
    method: 'GET'
  });
};

// 获取人员类别列表
export async function getMemberTypeList(params: any) {
  return request('/rucUserType/v1/rucUserType/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 获取项目代码列表
export async function getRelateProjectList(params: any) {
  return request('/ruProjectCode/api/v1/ruProjectCode/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 学生发放项目代码列表
export async function studentsDistributeProjectList() {
  return request('/api/studentsDistributeProjectCode/v1/projectCode/list', {
    method: 'GET'
  });
}

// 根据项目获取费别列表
export async function getProjectFeeRel(params: CostTypeInterface) {
  return request('/api/rucProjectFeeRel/v1/rucProjectFeeRel/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 获取标准单位字典列表
export async function getMatterStandardUnit() {
  return request('/rucUintType/v1/rucUintType', {
    method: 'GET'
  });
}

// 根据applyType获取支付方式列表
export async function getPaymentMethod(params: CostTypeInterface) {
  return request('/api/rucPaymentMethod/v1/rucPaymentMethod/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 学生申报获取授权的公文事项列表
export async function getAllowRucMatterList(params: any) {
  return request('/api/rucMatter/v1/rucMatter/apply/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 获取学生代码列表
export async function getStudentCodeList(params: any) {
  return request('/api/studentCode/v1/studentCode/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 获取校外人员采集表列表
export async function getOutsideUserList(params: any) {
  return request('/api/outsideUserInfo/v1/outsideUserInfo/list/keyword', {
    method: 'POST',
    data: { ...params }
  });
}

// 获取校内人员信息列表
export async function getInsideUserList(params: any) {
  return request('/rucInsideUserInfo/v1/rucInsideUserInfo/list', {
    method: 'POST',
    data: { ...params }
  });
}

// 获取事项标准表列表
// export async function getRucStandardList(params: any) {
//   return request('/rucStandard/v1/rucStandard/list', {
//     method: 'POST',
//     data: { ...params }
//   });
// }
// 获取公文事项表详情
export async function getRucStandardList(params: any) {
  // return request(`/api/rucMatter/v1/rucMatter/detail/${params}`, {
  //   method: 'GET'
  // });
  return request('/rucStandard/v1/rucStandard/list', {
    method: 'POST',
    data: { ...params }
  });
}

//催办
export async function doUrging(params: IUrgingProcessReq) {
  return request('/api/taskRecord/urgingProcess', {
    method: 'POST',
    data: { ...params }
  });
}

export async function isUrging(params: IUrgingProcessReq) {
  return request('/api/taskRecord/is/urgingProcess', {
    method: 'POST',
    data: { ...params }
  });
}

// 根据id获取文件
// export const GetFileById = async (id) => {
//   const res = await Request.get({
//     url: '/attachment/download',
//     responseType: 'blob',
//     custom: true,
//     params: { id }
//   });
//   return res;
// };

// 下载文件
// export const DownloadFileById = async (id, fileName) => {
//   const res = await GetFileById(id);
//   const blob = new Blob([res]);
//   const href = window.URL.createObjectURL(blob); //创建下载的链接
//   if (window.navigator.msSaveBlob) {
//     //IE浏览器
//     try {
//       window.navigator.msSaveBlob(blob, fileName);
//     } catch (e) {
//       console.log(e);
//     }
//   } else {
//     const link = document.createElement('a');
//     link.href = href;
//     link.style.display = 'none';
//     link.target = '_blank';
//     link.download = fileName;
//     document.body.appendChild(link);
//     link.click();
//     document.body.removeChild(link);
//     window.URL.revokeObjectURL(href); //释放掉blob对象
//   }
// };
